package de.htwg_konstanz.ebus.framework.view;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import de.htwg_konstanz.ebus.framework.wholesaler.api.bo.IBOOrder;
import de.htwg_konstanz.ebus.framework.wholesaler.api.boa.OrderBOA;

public class OrderListAction implements IAction {

	public static final String ACTION_SHOW_ORDER_LIST = "showOrderList";
	public static final String PARAM_ORDERS = "orders";
	
	public boolean accepts(String actionName) {
		return actionName.equals(ACTION_SHOW_ORDER_LIST);
	}

	public String execute(HttpServletRequest request, HttpServletResponse response, ArrayList<String> errorList) {
		
		List<IBOOrder> orders = OrderBOA.getInstance().findAll();
			
		request.getSession(true).setAttribute(PARAM_ORDERS, orders);					
		
		return "orders.jsp";
	}

}
